<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="70px"
    >
      <el-form-item label="委托人" prop="contractsName">
        <el-input
          v-model="queryParams.contractsName"
          placeholder="请输入委托人姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="被执行人" prop="executeName">
        <el-input
          v-model="queryParams.executeName"
          placeholder="请输入被执行人姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="执行进度" prop="schedule">
        <el-select
          v-model="queryParams.schedule"
          placeholder="执行进度"
          clearable
        >
          <el-option
            v-for="dict in dict.type.bus_schedule"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="初审" prop="checked">
        <el-select
          v-model="queryParams.checked"
          placeholder="初审状态"
          clearable
          style="width: 140px"
        >
          <el-option
            v-for="dict in dict.type.bus_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="复审" prop="repeatChecked">
        <el-select
          v-model="queryParams.repeatChecked"
          placeholder="复审状态"
          clearable
          style="width: 140px"
        >
          <el-option
            v-for="dict in dict.type.bus_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select
          v-model="queryParams.status"
          placeholder="状态"
          clearable
          style="width: 140px"
        >
          <el-option
            v-for="dict in dict.type.sys_common_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:contracts:add']"
          >新增</el-button
        >
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:contracts:edit']"
          >修改</el-button
        >
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:contracts:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:contracts:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="contractsList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="委托人姓名" align="center" prop="contractsName" />
      <el-table-column
        label="证件号码"
        align="center"
        prop="contractsIdnumber"
      />
      <el-table-column label="手机号码" align="center" prop="contractsMobile" />
      <el-table-column label="被执行人姓名" align="center" prop="executeName" />
      <el-table-column label="证件号码" align="center" prop="executeIdnumber" />
      <el-table-column label="执行进度" align="center" prop="schedule">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.bus_schedule"
            :value="scope.row.schedule"
          />
        </template>
      </el-table-column>
      <el-table-column label="初审" align="center" prop="checked">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.bus_status"
            :value="scope.row.checked"
          />
        </template>
      </el-table-column>
      <el-table-column label="复审" align="center" prop="repeatChecked">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.bus_status"
            :value="scope.row.repeatChecked"
          />
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status" width="100">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.sys_common_status"
            :value="scope.row.status"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:contracts:edit']"
            >查看</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:contracts:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改执行委托对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item label="委托人姓名" prop="contractsName">
          <template>
            <span>{{ form.contractsName }}</span>
          </template>
        </el-form-item>
        <el-form-item label="证件号码" prop="contractsIdnumber">
          <template>
            <span>{{ form.contractsIdnumber }}</span>
          </template>
        </el-form-item>
        <el-form-item label="手机号码" prop="contractsMobile">
          <template>
            <span>{{ form.contractsMobile }}</span>
          </template>
        </el-form-item>
        <el-form-item label="被执行人姓名" prop="executeName">
          <template>
            <span>{{ form.executeName }}</span>
          </template>
        </el-form-item>
        <el-form-item label="证件号码" prop="executeIdnumber">
          <template>
            <span>{{ form.executeIdnumber }}</span>
          </template>
        </el-form-item>
        <el-form-item label="执行进度" prop="schedule">
          <el-select
            :disabled="isUpdate"
            v-model="form.schedule"
            placeholder="执行进度"
            clearable
          >
            <el-option
              v-for="dict in dict.type.bus_schedule"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="前期支付费用" prop="brokerage1">
          <template>
            <span>{{ form.brokerage1 }}</span>
          </template>
        </el-form-item>
        <el-form-item label="后期支付比例" prop="brokerage2">
          <template>
            <span>{{ form.brokerage2 }}%</span>
          </template>
        </el-form-item>
        <el-form-item label="跟进律师" prop="incharge">
          <el-select
            filterable
            v-model="form.incharge"
            placeholder="跟进律师"
            clearable
          >
            <el-option
              v-for="item in userList"
              :key="item.userId"
              :label="item.nickName"
              :value="item.userId"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="初审" prop="checked">
          <el-radio-group v-model="form.checked">
            <el-radio
              v-for="dict in dict.type.bus_status"
              :key="dict.value"
              :label="dict.value"
              >{{ dict.label }}</el-radio
            >
          </el-radio-group>
        </el-form-item>
        <el-form-item label="复审" prop="repeatChecked">
          <el-radio-group v-model="form.repeatChecked">
            <el-radio
              v-for="dict in dict.type.bus_status"
              :key="dict.value"
              :label="dict.value"
              >{{ dict.label }}</el-radio
            >
          </el-radio-group>
        </el-form-item>
        <el-form-item
          label="驳回原因"
          prop="reason"
          v-if="form.repeatChecked == 3"
        >
          <el-input
            type="textarea"
            v-model="form.reason"
            placeholder="请输入驳回原因"
          />
        </el-form-item>
        <el-form-item label="状态" prop="status">
          <el-radio-group v-model="form.status">
            <el-radio
              v-for="dict in dict.type.sys_common_status"
              :key="dict.value"
              :label="dict.value"
              >{{ dict.label }}</el-radio
            >
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input
            v-model="form.remark"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item
          label="生效判决书"
          prop="file1"
          v-if="
            form.schedule == '生效未执行' ||
            form.schedule == '首次执行' ||
            form.schedule == '恢复执行'
          "
        >
          <el-link
            v-for="(file, index) in file1_fileList"
            :key="index"
            type="primary"
            :underline="false"
            @click="downloadFile(file.url)"
            ><el-image
              v-if="checkFileType(file.url)"
              style="width: 50px; height: 50px"
              :src="file.url"
              fit="contain"
            ></el-image>
            <el-image
              v-else
              style="width: 50px; height: 50px"
              src="https://fast.dgsiy.com/wechat/images/pdficon.png"
              fit="contain"
            ></el-image>
          </el-link>
        </el-form-item>
        <el-form-item
          label="执行申请书"
          prop="file2"
          v-if="form.schedule == '首次执行' || form.schedule == '恢复执行'"
        >
          <el-link
            v-for="(file, index) in file2_fileList"
            :key="index"
            type="primary"
            :underline="false"
            @click="downloadFile(file.url)"
            ><el-image
              v-if="checkFileType(file.url)"
              style="width: 50px; height: 50px"
              :src="file.url"
              fit="contain"
            ></el-image>
            <el-image
              v-else
              style="width: 50px; height: 50px"
              src="https://fast.dgsiy.com/wechat/images/pdficon.png"
              fit="contain"
            ></el-image>
          </el-link>
        </el-form-item>
        <el-form-item
          label="受理通知书"
          prop="file3"
          v-if="form.schedule == '首次执行' || form.schedule == '恢复执行'"
        >
          <el-link
            v-for="(file, index) in file3_fileList"
            :key="index"
            type="primary"
            :underline="false"
            @click="downloadFile(file.url)"
            ><el-image
              v-if="checkFileType(file.url)"
              style="width: 50px; height: 50px"
              :src="file.url"
              fit="contain"
            ></el-image>
            <el-image
              v-else
              style="width: 50px; height: 50px"
              src="https://fast.dgsiy.com/wechat/images/pdficon.png"
              fit="contain"
            ></el-image>
          </el-link>
        </el-form-item>
        <el-form-item
          label="恢复执行书"
          prop="file4"
          v-if="form.schedule == '恢复执行'"
        >
          <el-link
            v-for="(file, index) in file4_fileList"
            :key="index"
            type="primary"
            :underline="false"
            @click="downloadFile(file.url)"
            ><el-image
              v-if="checkFileType(file.url)"
              style="width: 50px; height: 50px"
              :src="file.url"
              fit="contain"
            ></el-image>
            <el-image
              v-else
              style="width: 50px; height: 50px"
              src="https://fast.dgsiy.com/wechat/images/pdficon.png"
              fit="contain"
            ></el-image>
          </el-link>
        </el-form-item>
        <el-form-item
          label="裁定书"
          prop="file5"
          v-if="form.schedule == '终本'"
        >
          <el-link
            v-for="(file, index) in file5_fileList"
            :key="index"
            type="primary"
            :underline="false"
            @click="downloadFile(file.url)"
            ><el-image
              v-if="checkFileType(file.url)"
              style="width: 50px; height: 50px"
              :src="file.url"
              fit="contain"
            ></el-image>
            <el-image
              v-else
              style="width: 50px; height: 50px"
              src="https://fast.dgsiy.com/wechat/images/pdficon.png"
              fit="contain"
            ></el-image>
          </el-link>
        </el-form-item>
        <!-- <el-form-item label="发布者签名" prop="remark">
          <el-link
            type="primary"
            :underline="false"
            @click="downloadFile(signimg)"
            ><el-image
              style="width: 350px; height: 250px; border: 1px solid #dddddd; border-radius: 4px;"
              :src="signimg"
              fit="contain"
            ></el-image>
          </el-link>
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="loadAgreement(17)">查看协议</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog
      title="协议内容"
      :visible.sync="agreementOpen"
      width="800px"
      :append-to-body="true"
      :modal-append-to-body="true"
    >
      <div v-html="agreementContent"></div>
      <div class="sign">
        <div class="signimg">
          <div>甲方：</div>
          <el-image
            style="width: 300px; height: 200px"
            :src="signimg"
            fit="contain"
          ></el-image>
        </div>
        <div class="signimg">
          <div>乙方：</div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listContracts,
  getContracts,
  delContracts,
  addContracts,
  updateContracts,
} from "@/api/business/contracts";
import { listUser } from "@/api/system/user";
import { getNews } from "@/api/business/news";
export default {
  name: "Contracts",
  dicts: [
    "bus_court",
    "bus_schedule",
    "bus_progress",
    "bus_status",
    "sys_common_status",
  ],
  data() {
    return {
      agreementOpen: false,
      agreementContent: undefined,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 执行委托表格数据
      contractsList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      isUpdate: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderByColumn: "updateTime desc,createTime desc",
        isAsc: "",
        contractsName: null,
        contractsIdnumber: null,
        contractsMobile: null,
        executeName: null,
        executeIdnumber: null,
        schedule: null,
        file1: null,
        file2: null,
        file3: null,
        file4: null,
        file5: null,
        incharge: null,
        checked: null,
        repeatChecked: null,
        status: null,
      },
      signimg: "",
      file1_fileList: [],
      file2_fileList: [],
      file3_fileList: [],
      file4_fileList: [],
      file5_fileList: [],
      userList: [],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        contractsName: [
          { required: true, message: "委托人姓名不能为空", trigger: "blur" },
        ],
        contractsIdnumber: [
          { required: true, message: "证件号码不能为空", trigger: "blur" },
        ],
        contractsMobile: [
          { required: true, message: "手机号码不能为空", trigger: "blur" },
        ],
        executeName: [
          { required: true, message: "被执行人姓名不能为空", trigger: "blur" },
        ],
        executeIdnumber: [
          { required: true, message: "证件号码不能为空", trigger: "blur" },
        ],
        schedule: [
          { required: true, message: "执行进度不能为空", trigger: "blur" },
        ],
        repeatChecked: [
          { required: true, message: "复审不能为空", trigger: "blur" },
        ],
        status: [{ required: true, message: "状态不能为空", trigger: "blur" }],
      },
    };
  },
  created() {
    this.getList();
    this.getUserList();
  },
  methods: {
    /** 查看协议内容 */
    loadAgreement(newsId) {
      this.agreementOpen = true;
      getNews(newsId).then((response) => {
        this.agreementContent = response.data.newsContent;
      });
    },
    /** 查询用户列表 */
    getUserList() {
      listUser({ userModel: 3 }).then((response) => {
        this.userList = response.rows;
      });
    },
    /** 查询执行委托列表 */
    getList() {
      this.loading = true;
      listContracts(this.queryParams).then((response) => {
        this.contractsList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 检查文件类型
    checkFileType(file) {
      // 创建一个正则表达式对象，用于匹配常见的图片、视频等文件格式
      const regex = /^.*\.(jpg|jpeg|png|gif)$/i;

      if (regex.test(file)) {
        return true; // 如果符合条件返回true
      } else {
        return false; // 否则返回false
      }
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        contractsId: null,
        contractsName: null,
        contractsIdnumber: null,
        contractsMobile: null,
        executeName: null,
        executeIdnumber: null,
        schedule: null,
        file1: null,
        file2: null,
        file3: null,
        file4: null,
        file5: null,
        incharge: null,
        checked: null,
        repeatChecked: null,
        status: "0",
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.contractsId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加执行委托";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const contractsId = row.contractsId || this.ids;
      getContracts(contractsId).then((response) => {
        const data = response.data;
        this.form = data;
        this.signimg = process.env.VUE_APP_BASE_API + data.signimg;
        if (data.file1) {
          const fileArr = data.file1.split(",");
          fileArr.forEach((item, index) => {
            const arr = item.split(":");
            this.file1_fileList.push({
              name: arr[0].split("/")[arr[0].split("/").length - 1],
              url: process.env.VUE_APP_BASE_API + arr[0],
            });
          });
        }
        if (data.file2) {
          const fileArr = data.file2.split(",");
          fileArr.forEach((item, index) => {
            const arr = item.split(":");
            this.file2_fileList.push({
              name: arr[0].split("/")[arr[0].split("/").length - 1],
              url: process.env.VUE_APP_BASE_API + arr[0],
            });
          });
        }
        if (data.file3) {
          const fileArr = data.file3.split(",");
          fileArr.forEach((item, index) => {
            const arr = item.split(":");
            this.file3_fileList.push({
              name: arr[0].split("/")[arr[0].split("/").length - 1],
              url: process.env.VUE_APP_BASE_API + arr[0],
            });
          });
        }
        if (data.file4) {
          const fileArr = data.file4.split(",");
          fileArr.forEach((item, index) => {
            const arr = item.split(":");
            this.file4_fileList.push({
              name: arr[0].split("/")[arr[0].split("/").length - 1],
              url: process.env.VUE_APP_BASE_API + arr[0],
            });
          });
        }
        if (data.file5) {
          const fileArr = data.file5.split(",");
          fileArr.forEach((item, index) => {
            const arr = item.split(":");
            this.file5_fileList.push({
              name: arr[0].split("/")[arr[0].split("/").length - 1],
              url: process.env.VUE_APP_BASE_API + arr[0],
            });
          });
        }
        this.open = true;
        this.title = "修改执行委托";
      });
    },
    downloadFile(url) {
      const fileUrl = url; // 文件的URL地址
      window.open(fileUrl);
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.contractsId != null) {
            updateContracts(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addContracts(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const contractsIds = row.contractsId || this.ids;
      this.$modal
        .confirm('是否确认删除执行委托编号为"' + contractsIds + '"的数据项？')
        .then(function () {
          return delContracts(contractsIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "business/contracts/export",
        {
          ...this.queryParams,
        },
        `contracts_${new Date().getTime()}.xlsx`
      );
    },
    /** 生效判决书上传 */
    file1BeforeUpload(file) {
      let isRightSize = file.size / 1024 / 1024 < 2;
      if (!isRightSize) {
        this.$message.error("文件大小超过 2MB");
      }
      let isAccept = new RegExp("image/*").test(file.type);
      if (!isAccept) {
        this.$message.error("应该选择image/*类型的文件");
      }
      let formData = new FormData();
      formData.append("offerFile", file);
      uploadFile(formData).then((response) => {
        const arr =
          file.name + ":" + process.env.VUE_APP_BASE_API + response.imgUrl;
        this.file1_fileList.unshift({
          name: file.name,
          url: process.env.VUE_APP_BASE_API + response.imgUrl,
        });
        this.file1_fileList.forEach((_item) => {
          if (this.form.file1 == "") {
            this.form.file1 = arr;
          } else {
            this.form.file1 = this.form.file1 + "," + arr;
          }
        });
        this.$modal.msgSuccess("上传成功");
      });
      return isRightSize && isAccept;
    },
    /** 生效判决书删除 */
    file1OnRemove(file, fileList) {
      this.form.file1 = "";
      this.file1_fileList = fileList;
      this.file1_fileList.forEach((_item) => {
        const arr = _item.name + ":" + _item.url;
        if (this.form.file1 == "") {
          this.form.file1 = arr;
        } else {
          this.form.file1 = this.form.file1 + "," + arr;
        }
      });
    },
    /** 执行申请书上传 */
    file2BeforeUpload(file) {
      let isRightSize = file.size / 1024 / 1024 < 2;
      if (!isRightSize) {
        this.$message.error("文件大小超过 2MB");
      }
      let isAccept = new RegExp("image/*").test(file.type);
      if (!isAccept) {
        this.$message.error("应该选择image/*类型的文件");
      }
      let formData = new FormData();
      formData.append("offerFile", file);
      uploadFile(formData).then((response) => {
        const arr =
          file.name + ":" + process.env.VUE_APP_BASE_API + response.imgUrl;
        this.file2_fileList.unshift({
          name: file.name,
          url: process.env.VUE_APP_BASE_API + response.imgUrl,
        });
        this.file2_fileList.forEach((_item) => {
          if (this.form.file2 == "") {
            this.form.file2 = arr;
          } else {
            this.form.file2 = this.form.file2 + "," + arr;
          }
        });
        this.$modal.msgSuccess("上传成功");
      });
      return isRightSize && isAccept;
    },

    /** 受理通知书上传 */
    file3BeforeUpload(file) {
      let isRightSize = file.size / 1024 / 1024 < 2;
      if (!isRightSize) {
        this.$message.error("文件大小超过 2MB");
      }
      let isAccept = new RegExp("image/*").test(file.type);
      if (!isAccept) {
        this.$message.error("应该选择image/*类型的文件");
      }
      let formData = new FormData();
      formData.append("offerFile", file);
      uploadFile(formData).then((response) => {
        const arr =
          file.name + ":" + process.env.VUE_APP_BASE_API + response.imgUrl;
        this.file3_fileList.unshift({
          name: file.name,
          url: process.env.VUE_APP_BASE_API + response.imgUrl,
        });
        this.file3_fileList.forEach((_item) => {
          if (this.form.file3 == "") {
            this.form.file3 = arr;
          } else {
            this.form.file3 = this.form.file3 + "," + arr;
          }
        });
        this.$modal.msgSuccess("上传成功");
      });
      return isRightSize && isAccept;
    },

    /** 恢复执行书上传 */
    file4BeforeUpload(file) {
      let isRightSize = file.size / 1024 / 1024 < 2;
      if (!isRightSize) {
        this.$message.error("文件大小超过 2MB");
      }
      let isAccept = new RegExp("image/*").test(file.type);
      if (!isAccept) {
        this.$message.error("应该选择image/*类型的文件");
      }
      let formData = new FormData();
      formData.append("offerFile", file);
      uploadFile(formData).then((response) => {
        const arr =
          file.name + ":" + process.env.VUE_APP_BASE_API + response.imgUrl;
        this.file4_fileList.unshift({
          name: file.name,
          url: process.env.VUE_APP_BASE_API + response.imgUrl,
        });
        this.file4_fileList.forEach((_item) => {
          if (this.form.file4 == "") {
            this.form.file4 = arr;
          } else {
            this.form.file4 = this.form.file4 + "," + arr;
          }
        });
        this.$modal.msgSuccess("上传成功");
      });
      return isRightSize && isAccept;
    },

    /** 裁定书上传 */
    file5BeforeUpload(file) {
      let isRightSize = file.size / 1024 / 1024 < 2;
      if (!isRightSize) {
        this.$message.error("文件大小超过 2MB");
      }
      let isAccept = new RegExp("image/*").test(file.type);
      if (!isAccept) {
        this.$message.error("应该选择image/*类型的文件");
      }
      let formData = new FormData();
      formData.append("offerFile", file);
      uploadFile(formData).then((response) => {
        const arr =
          file.name + ":" + process.env.VUE_APP_BASE_API + response.imgUrl;
        this.file5_fileList.unshift({
          name: file.name,
          url: process.env.VUE_APP_BASE_API + response.imgUrl,
        });
        this.file5_fileList.forEach((_item) => {
          if (this.form.file5 == "") {
            this.form.file5 = arr;
          } else {
            this.form.file5 = this.form.file5 + "," + arr;
          }
        });
        this.$modal.msgSuccess("上传成功");
      });
      return isRightSize && isAccept;
    },
    fileBeforeRemove(file, fileList) {
      return;
    },
  },
};
</script>

<style lang="scss" scope>
.el-image__inner {
  padding-right: 10px;
}
.sign {
  display: table;
  .signimg {
    width: 50%;
    padding: 20px;
    display: table-cell;
  }
}
</style>